<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div align="center">
    <h1>员工管理系统</h1>
    <div v-if="isLogin">
        <input type="text" placeholder="员工姓名" v-model="name">
        <input type="button" value="添加" @click="add()">
        <a href="javascript:void(0)" @click="outLogin()">退出登录</a>
    </div>

    <div v-else>
        <a href="">注册</a>
        <a href="javascript:void(0)" @click="login()">登录</a>
    </div>

    <table border="1">
        <caption>员工列表</caption>
        <tr>
            <th>编号</th>
            <th>姓名</th>
            <th v-if="isLogin">操作</th>
        </tr>
        <tr v-for="(name,i) in arr">
            <td>{{i + 1}}</td>
            <td>{{name}}</td>
            <td v-if="isLogin"><a href="javascript:void(0) " @click="del(i)">删除</a></td>
        </tr>

    </table>

</div>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
    let v = new Vue({
        el: "body>div",
        data: {
            isLogin: false,
            arr: ["云先生", "坎蒂丝", "迪希娅"],
            name: ""
        },
        methods: {

            add() {
                v.arr.push(v.name)
            },
            del(i) {
                v.arr.splice(i,1)
            },
            outLogin() {
                v.isLogin = false
            },
            login() {
                v.isLogin = true
            }
        }
    })
</script>
</body>
</html>